﻿using MF.HSD.UpdateSalePriceListIspBP;
using MF.HSD.UpdateSalePriceListIspBP.Proxy;
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls.WebParts;
using UFSoft.UBF.UI.ControlModel;
using UFSoft.UBF.UI.Engine.Builder;
using UFSoft.UBF.UI.MD.Runtime.Common;
using UFSoft.UBF.UI.WebControlAdapter;

namespace MF_HSD_UIPlug
{

    public partial class StandardSOMainUIFormWebPart : UFSoft.UBF.UI.Custom.ExtendedPartBase
    {

        public override void AfterInit(UFSoft.UBF.UI.IView.IPart part, EventArgs args)
        {
            this.Do_AfterInit(part, args); ;
        }

        #region 字段与属性                                       
        private UFIDA.U9.SCM.SM.SOUIModel.StandardSOMainUIFormWebPart _strongPart;
        IUFButton btnCreate = new UFWebButtonAdapter();
        #endregion
        private void Do_AfterInit(UFSoft.UBF.UI.IView.IPart part, EventArgs args)
        {
            #region 获取相关强类型数据                               

            _strongPart = part as UFIDA.U9.SCM.SM.SOUIModel.StandardSOMainUIFormWebPart;
            if (_strongPart == null)
                return;
            //初始化按钮
            IUFToolbar toolbar = (IUFToolbar)part.GetUFControlByName(part.TopLevelContainer, "Toolbar1");
            if (toolbar != null)
            {
                btnCreate = UIControlBuilder.BuilderToolbarButton(toolbar, "True", "btnCreateRcv", "True", "True", 60, 30, "28", "", true, false, "36BA88E0-FC28-402e-B9BA-3745A6771687", "36BA88E0-FC28-402e-B9BA-3745A6771687", "9307E981-85AA-4f19-ADB7-340D159F4A01");
                UIControlBuilder.SetButtonAccessKey(btnCreate);
                btnCreate.Text = "更新内部销售价格";
                btnCreate.ID = "btnCreateRcv";
                btnCreate.AutoPostBack = true;
                btnCreate.UIModel = part.Model.ElementID;
                ((UFWebToolbarAdapter)toolbar).Items.Add(btnCreate as System.Web.UI.WebControls.WebControl);
                btnCreate.Click += new EventHandler(btnCreate_Click);
            }
            #endregion
        }

        private void btnCreate_Click(object sender, EventArgs e)
        {
            _strongPart.OnDataCollect(this);
            _strongPart.IsDataBinding = true; //当前事件执行后会进行数据绑定
            _strongPart.IsConsuming = false;

            //跳转弹窗
            UpdateSalePriceProxy proxy = new UpdateSalePriceProxy();
            proxy.Do();
        }
    }
}
